Dear experienced Mates,
I have to solve the following little task:
An existing attrDXL code shall be placed into a column created by a script.
It's clear how to create a normal column and how to bound with a normal attribute.
But how could I create a column which based on an external script. This external script I got due to copying the attrDXL script which was made from DOORS by using the traceability wizards. Now I have to write a script that creates a column with this preserved script.
trac.dxl contains the extracted wizard script
My first attempts have been failed:
const string filename = "C:\\temp\\trac.dxl"
Buffer code = create
Stream input = read filename
while (!end of input) input >> code
Column col_ReqID, col_Trac
load view "Standard view"
delete column(0)
col_ReqID = insert column 0
attribute(col_ReqID, "Req.ID")
width(col_ReqID, 150)
title(col_ReqID, "Req.ID")
col_Trac = insert column 2
dxl(col_Trac, stringOf code)
width(col_Trac, 150)
title(col_Trac, "Backtrace")
refreshExplorer current Module
View v = view trgView
current = first current Module
save v
Thank You in advance,
vasgyuszi
vasgyuszi - Tue Jul 05 11:14:32 EDT 2011 |
|
Re: How to create an attrDXL column with dxl script SystemAdmin - Tue Jul 05 12:19:22 EDT 2011
What you are creating is a Column with Layout DXL. I tried it and is working ok. If you are talking about Attribute DXL, then is a different story. You need to create the DXL Attribute first and then display it into a column.
I am probably misunderstanding you.
FYI. There is a support tool that convert Layout DXL Scripts into DXL Attributes. Go to Tools > Support Tools > Convert Layout DXL to Attribute DXL.
|
|
Re: How to create an attrDXL column with dxl script vasgyuszi - Tue Jul 05 13:03:29 EDT 2011 SystemAdmin - Tue Jul 05 12:19:22 EDT 2011
What you are creating is a Column with Layout DXL. I tried it and is working ok. If you are talking about Attribute DXL, then is a different story. You need to create the DXL Attribute first and then display it into a column.
I am probably misunderstanding you.
FYI. There is a support tool that convert Layout DXL Scripts into DXL Attributes. Go to Tools > Support Tools > Convert Layout DXL to Attribute DXL.
Thanks for your answer.
What have You tried out? The code sequence I've copied? For me doesn't worked...
Okay, I was misleading in my wording. There is a difference between "layout DXL" and "DXL attribute".
In my case doesn't matter how I do solve the problem.
I converted the layout DXL to a DXL attribute (as you proposed) but I can't run it from a script. I have to embed it into a DXL script, that's my problem to be solved.
Best regards,
vasgyuszi
|
|
Re: How to create an attrDXL column with dxl script SystemAdmin - Tue Jul 05 14:10:00 EDT 2011 vasgyuszi - Tue Jul 05 13:03:29 EDT 2011
Thanks for your answer.
What have You tried out? The code sequence I've copied? For me doesn't worked...
Okay, I was misleading in my wording. There is a difference between "layout DXL" and "DXL attribute".
In my case doesn't matter how I do solve the problem.
I converted the layout DXL to a DXL attribute (as you proposed) but I can't run it from a script. I have to embed it into a DXL script, that's my problem to be solved.
Best regards,
vasgyuszi
Everything ran perfectly for me except for the View declaration
You can post the errors, if you have any
View v = view "trgView" //<< View name should be a string
|
|
Re: How to create an attrDXL column with dxl script Mathias Mamsch - Tue Jul 05 16:52:41 EDT 2011 vasgyuszi - Tue Jul 05 13:03:29 EDT 2011
Thanks for your answer.
What have You tried out? The code sequence I've copied? For me doesn't worked...
Okay, I was misleading in my wording. There is a difference between "layout DXL" and "DXL attribute".
In my case doesn't matter how I do solve the problem.
I converted the layout DXL to a DXL attribute (as you proposed) but I can't run it from a script. I have to embed it into a DXL script, that's my problem to be solved.
Best regards,
vasgyuszi
I am not entirely sure, that this is how you read an entire file! The >> operator will only read till the buffer end. It will also not append, but just overwrite the buffer in the next iteration. Did you actually check that the code you read from the file was correctly transferred to the layout column??
Try this with a large text file:
const string filename = "C:\\temp\\treedata.dtc"
Buffer code = create
Stream input = read filename
Buffer buf = create()
while (!end of input) { input >> code; combine (buf, code, 0) }
print length buf
print length code
Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: How to create an attrDXL column with dxl script llandale - Tue Jul 05 17:32:07 EDT 2011
The other comments seem to be appropriate; you are creating a layout column.
I'd be tempted to simply:
... code = readFile(filename)
Don't work much with views, but I'm pretty sure you need to have a ViewDef with a name, in order to save it. Since your code has no name of view, it appears to be trying to save the "Standard view" which won't work.
You want Attr DXL? Your filename will need to contain appropriate code, specifically "obj.attrDXLName" instead of "display" (for layouts). It may look like this:
Module mod = edit(the module)
current = mod
AttrDef ad = create(object type string dxl tempStringOf(code) attribute "MyAttrDxlName")
if (null ad) then definition didn't take
Then insert that attribute into your view.
|
|
Re: How to create an attrDXL column with dxl script vasgyuszi - Wed Jul 06 07:39:32 EDT 2011 llandale - Tue Jul 05 17:32:07 EDT 2011
The other comments seem to be appropriate; you are creating a layout column.
I'd be tempted to simply:
... code = readFile(filename)
Don't work much with views, but I'm pretty sure you need to have a ViewDef with a name, in order to save it. Since your code has no name of view, it appears to be trying to save the "Standard view" which won't work.
You want Attr DXL? Your filename will need to contain appropriate code, specifically "obj.attrDXLName" instead of "display" (for layouts). It may look like this:
Module mod = edit(the module)
current = mod
AttrDef ad = create(object type string dxl tempStringOf(code) attribute "MyAttrDxlName")
if (null ad) then definition didn't take
Then insert that attribute into your view.
Thanks Louie,
the view handling is okay, but I haven't copied all the stuff.
I'll report when I tried your suggestions.
regards,
vasgyuszi
|
|
Re: How to create an attrDXL column with dxl script vasgyuszi - Wed Jul 06 11:02:34 EDT 2011 llandale - Tue Jul 05 17:32:07 EDT 2011
The other comments seem to be appropriate; you are creating a layout column.
I'd be tempted to simply:
... code = readFile(filename)
Don't work much with views, but I'm pretty sure you need to have a ViewDef with a name, in order to save it. Since your code has no name of view, it appears to be trying to save the "Standard view" which won't work.
You want Attr DXL? Your filename will need to contain appropriate code, specifically "obj.attrDXLName" instead of "display" (for layouts). It may look like this:
Module mod = edit(the module)
current = mod
AttrDef ad = create(object type string dxl tempStringOf(code) attribute "MyAttrDxlName")
if (null ad) then definition didn't take
Then insert that attribute into your view.
Hi Louie, and all the nice Mates here,
I've just made tihs mods on your code to get it work:
AttrDef ad = create object type "String" attribute "MyAttrDxlName" dxl tempStringOf(code)
if (null ad) then errorBox "Attribute wasn't created!"
No the script runs but won't eat my previously extracted attribute DXL file, which I've generated with DOORS convert utility from the working layout DXL. It looks like:
What do I miss?
THX,
vasgyuszi
Attachments
attachment_14637179_trac_attrDXL.dxl
|
|
Re: How to create an attrDXL column with dxl script Mathias Mamsch - Thu Jul 07 03:37:58 EDT 2011 vasgyuszi - Wed Jul 06 11:02:34 EDT 2011
Hi Louie, and all the nice Mates here,
I've just made tihs mods on your code to get it work:
AttrDef ad = create object type "String" attribute "MyAttrDxlName" dxl tempStringOf(code)
if (null ad) then errorBox "Attribute wasn't created!"
No the script runs but won't eat my previously extracted attribute DXL file, which I've generated with DOORS convert utility from the working layout DXL. It looks like:
What do I miss?
THX,
vasgyuszi
I already told you: the code that you use to read the file does not work. See my previous post. Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
|
Re: How to create an attrDXL column with dxl script vasgyuszi - Thu Jul 07 07:28:14 EDT 2011 Mathias Mamsch - Thu Jul 07 03:37:58 EDT 2011
I already told you: the code that you use to read the file does not work. See my previous post. Regards, Mathias
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Sorry Mathias, I have forgot to respond on it:
well, I've changed the routine as follows:
const string filename = "C:\\temp\\trac_attrDXL.dxl"
Buffer code = create
Stream input = read filename
string tStr = ""
while (!end of input) {input >> tStr; code += tStr "\n"}
close input
The only problem remains that the code won't be executed. When I open the attribute properties and hit on current, I get back the dxl code. But no results will be displayed within the column... ?
Previously I've attached the file I'm reading in. (trac_attrDXL.dxl)
Thank you again,
vasgyuszi
|
|
Re: How to create an attrDXL column with dxl script llandale - Thu Jul 07 10:30:54 EDT 2011 vasgyuszi - Thu Jul 07 07:28:14 EDT 2011
Sorry Mathias, I have forgot to respond on it:
well, I've changed the routine as follows:
const string filename = "C:\\temp\\trac_attrDXL.dxl"
Buffer code = create
Stream input = read filename
string tStr = ""
while (!end of input) {input >> tStr; code += tStr "\n"}
close input
The only problem remains that the code won't be executed. When I open the attribute properties and hit on current, I get back the dxl code. But no results will be displayed within the column... ?
Previously I've attached the file I'm reading in. (trac_attrDXL.dxl)
Thank you again,
vasgyuszi
That is a layout because it contains "displayRich" and contains no "obj.attrDXLName =". The various 'display' functions only do something in a layout.
Insert that code into a layout column, then use the utility to convert it to an attr DXL. Edit that attr and get it to do what you want, then copy the DXL into your file. You will notice the difference is that the various "display" functions are re-coded at the top to accumulate the results in a buffer, allowing it to be assigned the value at the bottom.
|
|
Re: How to create an attrDXL column with dxl script llandale - Thu Jul 07 10:32:12 EDT 2011 llandale - Thu Jul 07 10:30:54 EDT 2011
That is a layout because it contains "displayRich" and contains no "obj.attrDXLName =". The various 'display' functions only do something in a layout.
Insert that code into a layout column, then use the utility to convert it to an attr DXL. Edit that attr and get it to do what you want, then copy the DXL into your file. You will notice the difference is that the various "display" functions are re-coded at the top to accumulate the results in a buffer, allowing it to be assigned the value at the bottom.
Oops, never mind. Really should have read the code more carefully. It is converted layout.
|
|
Re: How to create an attrDXL column with dxl script llandale - Thu Jul 07 10:48:23 EDT 2011 vasgyuszi - Thu Jul 07 07:28:14 EDT 2011
Sorry Mathias, I have forgot to respond on it:
well, I've changed the routine as follows:
const string filename = "C:\\temp\\trac_attrDXL.dxl"
Buffer code = create
Stream input = read filename
string tStr = ""
while (!end of input) {input >> tStr; code += tStr "\n"}
close input
The only problem remains that the code won't be executed. When I open the attribute properties and hit on current, I get back the dxl code. But no results will be displayed within the column... ?
Previously I've attached the file I'm reading in. (trac_attrDXL.dxl)
Thank you again,
vasgyuszi
That attr-DXL will display the "Req.ID" attr value of objects that source links to the current object, so long as the source object is in this one specific module with ID "3daadaf404585fe2-000127a1".
If you are linking from some other module, or that module has no such attribute named "Req.ID", or all the values are blank, then this attr-DXL won't display anything.
Open a DXL windows and run this:
Item itm = itemFromID("3daadaf404585fe2-000127a1")
if (null itm) //
then print "no such module\n"
else print "Source name: " name(itm) "\t" fullName(itm) "\n"
|
|
Re: How to create an attrDXL column with dxl script vasgyuszi - Thu Jul 07 13:36:32 EDT 2011 llandale - Thu Jul 07 10:48:23 EDT 2011
That attr-DXL will display the "Req.ID" attr value of objects that source links to the current object, so long as the source object is in this one specific module with ID "3daadaf404585fe2-000127a1".
If you are linking from some other module, or that module has no such attribute named "Req.ID", or all the values are blank, then this attr-DXL won't display anything.
Open a DXL windows and run this:
Item itm = itemFromID("3daadaf404585fe2-000127a1")
if (null itm) //
then print "no such module\n"
else print "Source name: " name(itm) "\t" fullName(itm) "\n"
Dear Louie,
what does it mean that number?
string limitModules[1] = {"3daadaf404585fe2-000127a1"}
I wanna use my dxl script for many different modules. If this number an ID for that one module where I got the attrDXL script, that I can't use it for other modules, isn't it?
THX,
vasgyuszi
|
|
Re: How to create an attrDXL column with dxl script vasgyuszi - Thu Jul 07 13:44:30 EDT 2011 vasgyuszi - Thu Jul 07 13:36:32 EDT 2011
Dear Louie,
what does it mean that number?
string limitModules[1] = {"3daadaf404585fe2-000127a1"}
I wanna use my dxl script for many different modules. If this number an ID for that one module where I got the attrDXL script, that I can't use it for other modules, isn't it?
THX,
vasgyuszi
n addition: of course all the modules I will work with, have the same attribute base (each has Req.ID and so on) So this shall be not the problem.
|
|
Re: How to create an attrDXL column with dxl script llandale - Thu Jul 07 13:49:47 EDT 2011 vasgyuszi - Thu Jul 07 13:36:32 EDT 2011
Dear Louie,
what does it mean that number?
string limitModules[1] = {"3daadaf404585fe2-000127a1"}
I wanna use my dxl script for many different modules. If this number an ID for that one module where I got the attrDXL script, that I can't use it for other modules, isn't it?
THX,
vasgyuszi
That's the unique ID of the module you defined as being the only one you care about when you used the Wizard to create that layout originally. I can see why that notion was implemented this way (you can rename and move the module and the layout still works) but I don't like it; the layout is destroyed when you archive-restore and you cannot use it for other purposes. Restoring and re-use are FAR more common than moving and renaming.
Create another layout with the wizard allowing for all source modules. If you only want SOME other modules then it gets trickier, but we can modify the layout to ignore modules that lack the "Req.ID" attribute, which I suspect is what you may want. Also perhaps ignore null "Req.ID" values which I think is better. Get the layout working, then convert to attrDXL would be fastest.
|
|
Re: How to create an attrDXL column with dxl script vasgyuszi - Fri Jul 08 10:07:12 EDT 2011 llandale - Thu Jul 07 13:49:47 EDT 2011
That's the unique ID of the module you defined as being the only one you care about when you used the Wizard to create that layout originally. I can see why that notion was implemented this way (you can rename and move the module and the layout still works) but I don't like it; the layout is destroyed when you archive-restore and you cannot use it for other purposes. Restoring and re-use are FAR more common than moving and renaming.
Create another layout with the wizard allowing for all source modules. If you only want SOME other modules then it gets trickier, but we can modify the layout to ignore modules that lack the "Req.ID" attribute, which I suspect is what you may want. Also perhaps ignore null "Req.ID" values which I think is better. Get the layout working, then convert to attrDXL would be fastest.
Hi,
wow, now does work. I've made exactly as you proposed and now I see the results in the attribute DXL column.
There is only a little problem remaining: it will be always only three links evaluated and displayed within the attribute. If the object has =< 3 inlinks, than works fine, but at objects with more than 3 inlinks it displays only the first three hits and not anymore.
As I'm surfing between the objects I got some interesting error message:
-R-W- DXL: <Line:14> value assigned to string attribute 'MyAttrDxlName' truncated
Backtrace:
<Line:125>
The accordant script lines were (taken from the converted version):
14: obj.attrDXLName = richText tempStringOf(bsz)
125: endAttributeDXL()
Any idea why this happens?
Best regards,
vasgyuszi
|
|
Re: How to create an attrDXL column with dxl script llandale - Fri Jul 08 11:09:15 EDT 2011 vasgyuszi - Fri Jul 08 10:07:12 EDT 2011
Hi,
wow, now does work. I've made exactly as you proposed and now I see the results in the attribute DXL column.
There is only a little problem remaining: it will be always only three links evaluated and displayed within the attribute. If the object has =< 3 inlinks, than works fine, but at objects with more than 3 inlinks it displays only the first three hits and not anymore.
As I'm surfing between the objects I got some interesting error message:
-R-W- DXL: <Line:14> value assigned to string attribute 'MyAttrDxlName' truncated
Backtrace:
<Line:125>
The accordant script lines were (taken from the converted version):
14: obj.attrDXLName = richText tempStringOf(bsz)
125: endAttributeDXL()
Any idea why this happens?
Best regards,
vasgyuszi
Type 'String' attributes have a maximum length of 968 characters, but I hear tell it varies a little on different servers. Looks like you need to change the type of your DXL attribute to 'Text'. But since you cannot change the type of an attribute you will need to make a new one:
o Rename the existing 'string' attribute.
o edit and copy its DXL
o Create new attr with the old name type 'Text'
o Paste the copied DXL.
o OK attr
o Delete the old attrDXL
o save module.
Run this dxl:
print "Max 'string' attr length for this database is = " maximumAttributeLength "\n"
print "This attr length: " length(probeAttr_((current Object), "MyAttrDxlName")) "\n"
|
|
Re: How to create an attrDXL column with dxl script vasgyuszi - Mon Jul 11 10:41:56 EDT 2011 llandale - Fri Jul 08 11:09:15 EDT 2011
Type 'String' attributes have a maximum length of 968 characters, but I hear tell it varies a little on different servers. Looks like you need to change the type of your DXL attribute to 'Text'. But since you cannot change the type of an attribute you will need to make a new one:
o Rename the existing 'string' attribute.
o edit and copy its DXL
o Create new attr with the old name type 'Text'
o Paste the copied DXL.
o OK attr
o Delete the old attrDXL
o save module.
Run this dxl:
print "Max 'string' attr length for this database is = " maximumAttributeLength "\n"
print "This attr length: " length(probeAttr_((current Object), "MyAttrDxlName")) "\n"
Dear Louie,
thank You again! That's really helped and now all the problems are solved :)
I'm in the lucky situation to have access on the attributes, so I changed it to "Text" and the error message are gone.
Best regards,
vasgyuszi
|
|